﻿//----------------------------------------------------------------------------
// Copyright (c) Pavel Tishkin 2012-2013.
//
// You must not remove this notice, or any other, from this software.
//----------------------------------------------------------------------------

namespace Lib.Dxp.Orm



module DataValueInit =
    //let (|Default|) defaultValue input =
    //    defaultArg input defaultValue

    let inline varchar (max : int)  = DataValue("", MaxLength = max, IsNullable = true)
    let inline text    () = DataValue("", IsNullable    = true)
    let inline int     () = DataValue(0,  IsNullable    = true)
    let inline date    () = DataValue(System.DateTime(1900, 1, 1), IsNullable = true)
    let inline money   () = DataValue(0m, IsNullable    = true)
    let inline decimal () = DataValue(0m, IsNullable    = true)
    let inline double  () = DataValue(0.0, IsNullable   = true)

    //let inline flags<'a when 'a : equality and 'a :> enum<_>> () = DataValue(Unchecked.defaultof<'a>,  IsNullable    = true)    
    let inline link    () = DataValue(0, IsNullable     = true)
    
    let inline var (a : ^a)         = DataValue<_>(a)
    let inline dyn (a : ^a)         = DataValue<_>(a, IsDynamic = true)

    module NotNull =
        let inline varchar (max : int)  = DataValue("", MaxLength = max, IsNullable = false)
        let inline text    () = DataValue("", IsNullable    = false)
        let inline int     () = DataValue(0,  IsNullable    = false)
        let inline date    () = DataValue(System.DateTime(1900, 1, 1), IsNullable = false)
        let inline money   () = DataValue(0m, IsNullable    = false)
        let inline decimal () = DataValue(0m, IsNullable    = false)
        let inline double  () = DataValue(0.0, IsNullable   = false)

        //let inline flags<'a when 'a : equality and 'a :> System.Enum> () = DataValue(Unchecked.defaultof<'a>,  IsNullable    = false)
        let inline link    () = DataValue(0, IsNullable     = false)
